﻿INSERT INTO [Flights] (
    [SessionID]
   ,[AircraftID]
   ,[StartTime]
   ,[EndTime]
   ,[Callsign]
   ,[NumPosMsgRec]
   ,[NumADSBMsgRec]
   ,[NumModeSMsgRec]
   ,[NumIDMsgRec]
   ,[NumSurPosMsgRec]
   ,[NumAirPosMsgRec]
   ,[NumAirVelMsgRec]
   ,[NumSurAltMsgRec]
   ,[NumSurIDMsgRec]
   ,[NumAirToAirMsgRec]
   ,[NumAirCallRepMsgRec]
   ,[FirstIsOnGround]
   ,[LastIsOnGround]
   ,[FirstLat]
   ,[LastLat]
   ,[FirstLon]
   ,[LastLon]
   ,[FirstGroundSpeed]
   ,[LastGroundSpeed]
   ,[FirstAltitude]
   ,[LastAltitude]
   ,[FirstVerticalRate]
   ,[LastVerticalRate]
   ,[FirstTrack]
   ,[LastTrack]
   ,[FirstSquawk]
   ,[LastSquawk]
   ,[HadAlert]
   ,[HadEmergency]
   ,[HadSPI]
) VALUES (
    @sessionID
   ,@aircraftID
   ,@startTime
   ,@endTime
   ,@callsign
   ,@numPosMsgRec
   ,@numADSBMsgRec
   ,@numModeSMsgRec
   ,@numIDMsgRec
   ,@numSurPosMsgRec
   ,@numAirPosMsgRec
   ,@numAirVelMsgRec
   ,@numSurAltMsgRec
   ,@numSurIDMsgRec
   ,@numAirToAirMsgRec
   ,@numAirCallRepMsgRec
   ,@firstIsOnGround
   ,@lastIsOnGround
   ,@firstLat
   ,@lastLat
   ,@firstLon
   ,@lastLon
   ,@firstGroundSpeed
   ,@lastGroundSpeed
   ,@firstAltitude
   ,@lastAltitude
   ,@firstVerticalRate
   ,@lastVerticalRate
   ,@firstTrack
   ,@lastTrack
   ,@firstSquawk
   ,@lastSquawk
   ,@hadAlert
   ,@hadEmergency
   ,@hadSPI
);
SELECT [FlightID] FROM [Flights] WHERE _ROWID_ = last_insert_rowid();
